<div class="SipeiInfo border_3 pt20 pb20 centered back_bgf"><!--选修课等级分数设置-弹窗-新增-->
    <form method='post' action='<?php echo $this->createUrl('/question_collect/default/add') ?>'  id="searchForm" target="ajax-frame">
        <table width="473" class="fontc_666 height32">
            <tbody>
                <tr height="55">
                    <td valign="top" align="right" width="120" class="pr5"><span class="pr5 fontc_orange_red">*</span>考试项目：</td>
                    <td valign="top" width="348" class="formValidator_td">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select name="info[exam_id]" id="exam_id" class="fl fontc_666" onchange="checksubject(this.value)">
                                    <option value="">请选择</option>
                                    <?php if ($date['examall']): foreach ($date['examall'] as $one): ?>
                                            <option value="<?php echo $one['exam_id']; ?>"><?php echo $one['exam_term_name']; ?></option>
                                            <?php
                                            endforeach;
                                            endif;
                                    ?>
                                </select>
                            </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="exam_idTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr height="55">
                    <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>所属科目：</td>
                    <td valign="top"  class="formValidator_td">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select name="info[subject_id]" id="subject_id" class="fl fontc_666" onchange="getallfields(this.value)">
                                    <option value="">请选择</option>
                                    <?php if ($date['subjectall']): foreach ($date['subjectall'] as $one): ?>
                                            <option value="<?php echo $one['subject_id']; ?>"><?php echo $one['subject_name']; ?></option>
                                            <?php
                                            endforeach;
                                            endif;
                                    ?>
                                </select>
                            </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="subject_idTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr height="55">
                    <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>汇总栏位：</td>
                    <td valign="top"  class="formValidator_td">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select name="info[collect_fields]" id="collect_fields" class="fl fontc_666">
                                    <option value="">请选择</option>
                                    <?php if ($date['row_config']): foreach ($date['row_config'] as $k => $one): ?>
                                            <option value="<?php echo $k; ?>"><?php echo $one; ?></option>
                                            <?php
                                            endforeach;
                                            endif;
                                    ?>
                                </select>
                            </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="collect_fieldsTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr height="55">
                    <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>汇总方式：</td>
                    <td valign="top"  class="formValidator_td">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select name="info[collect_mode]" id="collect_mode" class="fl fontc_666">
                                    <option value="">请选择</option>
                                    <?php if ($date['collect_mode']): foreach ($date['collect_mode'] as $k => $v): ?>
                                            <option value="<?php echo $k; ?>"><?php echo $v; ?></option>
                                            <?php
                                            endforeach;
                                            endif;
                                    ?>
                                </select>
                            </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="collect_modeTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr id="mode1" class="mode" style="display:none">
                    <td valign="top" align="right" class="pr5">题型选择：</td>
                    <td valign="top" class="pt10 pb10" >
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select name="info[collect_questions]" id="collect_questions" class="fl fontc_666">
                                    <option value="">请选择</option>
                                </select>
                            </span>
                        </span>
                    </td>
                </tr>
                <tr height="55">
                    <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>题号包含'_'不统计：</td>
                    <td valign="top"  class="formValidator_td">
                        <span class="fl standard_select pt5 pr7 pb5 pl3  border_3">
                            <span class="fl select_shelter">
                                <input type="checkbox" name="info[no_statis_unline]" checked="checked" value="1">
                            </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="collect_modeTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr height="55">
                    <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>保留小数位：</td>
                    <td valign="top"  class="formValidator_td">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select name="info[dot_num]"  class="fl fontc_666">
                                    <option value="0" selected='selected'>0</option>
                                    <option value="1">1</option>
                                </select>
                            </span>
                        </span>
                        <div class="formValidator_tip">
                            <p id="collect_modeTip" ></p>
                        </div>
                    </td>
                </tr>
                <tr height="55" id="mode2" class="mode" style="display:none">
                    <td valign="top" align="right" class="pt15 pr5">题号选择：</td>
                    <td valign="top"  class="pt10 pb10">
                        <div class="select_t_select" style="clear:both;">
                            <div class="dep_ben_list fl">
                                <div class="ben_title"></div>
                                <select id="user_select" size="3" multiple="" style="width:90px;height:150px;" ></select>
                            </div>
                            <div class="dep_ben_btn fl"> 
                                <a style="display:block; margin:10px 5px; margin-top:40px;" class="right" href="javascript:;">
								<img src="/themes/default/images/Sipei/btn_ben_right.gif"></a> 
                                <a  style="display:block; margin:10px 5px;" class="left" href="javascript:;">
								<img src="/themes/default/images/Sipei/btn_ben_left.gif"></a> 
                            </div>
                            <div class="dep_ben_list fl">
                                <div class="ben_title"></div>
                                <select name="info[collect_question][]" id="userNameSelected" size="3" multiple="" style="width:90px;height:150px;"></select>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="pr5 pb20"></td>
                    <td valign="top"  class="pb20">
                        <input type="submit" value="保存" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 mr10 cursor" name="submit" />
                        <input type="button" onclick="api.close();" value="取消" class="b_a_n border_3 back_bgb w80 height32 fontc_FFF fonts_12 cursor" />
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
<iframe src='' style="display:none" name='ajax-frame'></iframe>
<script>
$(function() {
	$(".select_t").bind("click", function() {
		$(".select_t_select").show();
	});
	var oUser = $('#user_select');
	$('.right').click(function() {
		var s = oUser.find('option:selected');
		$('#userNameSelected').find("option").attr("selected", false)
		s.appendTo($('#userNameSelected'));
		return false;
	});
	$('.left').click(function() {
		var s = $('#userNameSelected').find('option:selected');
		s.appendTo(oUser);
		return false;
	});
})

//获取栏位
function getallfields(subject_id) {
	var collect_mode = $("#collect_mode").val();
	if (collect_mode != '') {
		getmode(collect_mode);
	}
}
//项目科目联动
function checksubject(val){
	$.post('/question_collect/default/ajaxvalue', {id: val}, function(result) {
		var dataObj=eval("("+result+")");//转换为json对象
		var subjectstr = '';
		$.each(dataObj,function(i,item){
			subjectstr += "<option value='" + item.subject_id + "'>" + item.subject_name + "</option>"
		});
		$("#subject_id").html(subjectstr);
	});
}
function getmode(val) {
	var msg="";
	var exam_id = $("#exam_id").val();
	var subject_id = $("#subject_id").val();
	if (exam_id == '' || subject_id == '') {
		msg="请选择项目和科目";
	} else {
		if (val == 1) {
			$.post('/question_collect/default/sujectquestions', {subject_id: subject_id}, function(result) {
				var obj = $.parseJSON(result), newHtml = "";
				$.each(obj, function(i, item) {
					newHtml += "<option value='" + i + "'>" + item + "</option>"
				})
				$("#collect_questions").html(newHtml);
			});
		}
		if (val == 2) {
			$.post('/question_collect/default/sujectquestion', {exam_id: exam_id, subject_id: subject_id}, function(result) {
				var obj = $.parseJSON(result), newHtml = "";
				$.each(obj, function(i, item) {
					newHtml += "<option value='" + item['id'] + "'>" + item['num_id'] + "</option>"
				})
				$("#user_select").html(newHtml);
			});
		}
		$(".mode").hide();
		$("#mode" + val).show();
		msg = true;
	}
	return msg;
}
$("#searchForm").submit(function(){
	 $("#userNameSelected option").attr("selected", true);
})


$(function(){
	$.formValidator.initConfig({formID:"searchForm",theme:"126",submitOnce:false,
	onError:function(msg,obj,errorlist){
		$("#errorlist").empty();
		$.map(errorlist,function(msg){
			$("#errorlist").append("<li>" + msg + "</li>")
		});
		alert(msg);
	},
	ajaxPrompt : '有数据正在异步验证，请稍等...'
	});
	/*考试项目验证*/
	$("#exam_id").formValidator({
		onShowText:"请输入考试项目",
		onShow:"",
		onFocus:"",
		onCorrect:"输入正确",
		leftTrim:true,
		rightTrim:true
	}).inputValidator({
		min:1,
		onError:"考试项目不能为空"
	});
	/*所属科目验证*/
	/*	$("#subject_id").formValidator({
	onShowText:"请输入所属科目",
	onShow:"",
	onFocus:"",
	onCorrect:"输入正确",
	leftTrim:true,
	rightTrim:true
	}).inputValidator({
	min:1,
	onError:"所属科目不能为空"
	});*/
	/*汇总栏位验证*/
	$("#collect_fields").formValidator({
		onShowText:"请输入汇总栏位",
		onShow:"",
		onFocus:"",
		onCorrect:"输入正确",
		leftTrim:true,
		rightTrim:true
	}).inputValidator({
		min:1,
		onError:"汇总栏位不能为空"
	});
	/*汇总方式验证*/
	$("#collect_mode").formValidator({
		onShowText:"请输入汇总方式",
		onShow:"",
		onFocus:"",
		onCorrect:"输入正确",
		leftTrim:true,
		rightTrim:true
	}).inputValidator({
		min:1,
		onError:"汇总方式不能为空"
	}).functionValidator({fun:getmode});
})
</script>
<?php exit; ?>